﻿@using IterationLife.Extensions.EasyUI.GridColumns
@using IterationLife.FootballTeaching.Queries
@using Util.Ui
@model IterationLife.PlatformBackEnd.AppServices.Dtos.FootballTeachings.CourseDto
@{
    var x = @Html.EasyUi();
}
<script type="text/javascript">

    var grid_course_refresh = function () {
        $.easyui.refresh("formQuery_course", "grid_course");
    }

    var panel_course_refresh = function (id) {
        $.easyui.refreshPanel("panel_chapters", "/FootballTeachings/chapter/Grid?courseId=" + id);
    }

    var panel_course_onGridClickRow = function (index, row) {
        panel_course_refresh(row.Id);
    }

    var panel_course_onLoadSuccess = function (data) {
        if (data.total === 0) {
            panel_course_refresh("");
            return;
        }
        panel_course_refresh(data.rows[0].Id);
    }
</script>

@using (x.Layout(true).Begin())
{
    using (x.LayoutRegion().Top().Height(32).Begin())
    {
        <div class="toolbar">
            @x.DialogButton("添加课程", "/FootballTeachings/course/add").Icon("icon-add").Plain().OnClose("grid_course_refresh").DialogSize(700, 580)
            @x.DialogButton("编辑课程", "/FootballTeachings/course/edit").Id("btnEdit_course").Icon("icon-edit").Plain().ShowEditDialog("grid_course").OnClose("grid_course_refresh").DialogSize(700, 580)
            @x.Button("删除课程").Icon("icon-delete").Plain().Delete("/FootballTeachings/course/delete", "", "grid_course")
            @x.DialogButton("查看详细", "/FootballTeachings/course/detail").Id("btnLook").Icon("icon-look").Plain().ShowDetailDialog("grid_course").DialogSize(860,450)
            @x.Button("刷 新").Icon("icon-refresh").Plain().Refresh("formQuery_course", "grid_course")
        </div>
    }
    using (x.LayoutRegion().Center().Begin())
    {
        @Html.Partial("Parts/QueryForm", new CourseQuery())
        @(x.Grid("grid_course").Sort("SortId", false).Toolbar("divQuery_course").Url("/FootballTeachings/Course/PagerQuery")
                      .ShowEditDialogByDblClick("btnEdit_course").Menu().FitColumns().Fit()
                      .Columns(
                          x.GridColumn(t => t.Id).CheckBox(),
                          x.GridColumn(t => t.Name, 100),
                          x.GridColumn(t => t.Banner, 100).AttachmentPreview(),
                          x.GridColumn(t => t.CourseCategoryNames, 100),
                          x.GridColumn(t => t.PlayerPositionNames, 100),
                          x.GridColumn(t => t.Difficulty, 100)
                      )
                      .AddDataOption("onClickRow", "panel_course_onGridClickRow")
                      .OnLoadSuccess("panel_course_onLoadSuccess")
        )
    }
}